package com.bee.beemanage.system.common.utils.exceptions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

public class ExceptionUtils {
    private static final Logger logger = LoggerFactory.getLogger(ExceptionUtils.class);

    public static String getFullStackTrace(Throwable throwable) {
        String fullStackTrace = throwable.getLocalizedMessage();
        ByteArrayOutputStream byteStr = new ByteArrayOutputStream();

        try {
            throwable.printStackTrace(new PrintWriter(byteStr, true));
            fullStackTrace = byteStr.toString();
        } catch (Exception e) {
            logger.error(e.getMessage());
        } finally {
            try {
                byteStr.close();
            } catch (Exception e2) {
                logger.error(e2.getMessage());
            }
        }

        return fullStackTrace;
    }
}